﻿using RimWorld;
using RimWorld.Planet;
using RimWorld.QuestGen;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Verse;
using Verse.Grammar;

namespace SZ.Mech//还有刷新更改
{
    public class SitePartWorker_DanFurnaceRoom : SitePartWorker
    {
        public override void Init(Site site, SitePart sitePart)//生成遗迹的faction必须地图的父类，必须强制设置派系
        {
            base.Init(site, sitePart);
            //直接就可以改派系日
            site.SetFaction(Find.FactionManager.FirstFactionOfDef(SZ_DefOf.SZ_HeavenForgedCelestiall));
            sitePart.relicThing = sitePart.parms.relicThing;
            

        }
        public override SitePartParams GenerateDefaultParams(float myThreatPoints, int tile, Faction faction)
        {
            
            SitePartParams sitePartParams = base.GenerateDefaultParams(myThreatPoints, tile,Find.FactionManager.FirstFactionOfDef(SZ_DefOf.SZ_HeavenForgedCelestiall));
            sitePartParams.threatPoints = Mathf.Max(sitePartParams.threatPoints, 750f);
            return sitePartParams;
        }
        //public override bool FactionCanOwn(Faction faction)
        //{
        //    if(faction==Faction.OfAncients)
        //    {
        //        return true;
        //    }
        //    return base.FactionCanOwn(faction);
        //}


        //public bool ShouldKeepMapForRelic(SitePart sitePart)
        //{
        //    if (sitePart.relicThing != null && !sitePart.relicThing.DestroyedOrNull())
        //    {
        //        return sitePart.relicThing.MapHeld == sitePart.site.Map;
        //    }
        //    return false;
        //}

        //public override void Notify_SiteMapAboutToBeRemoved(SitePart sitePart)
        //{
        //    base.Notify_SiteMapAboutToBeRemoved(sitePart);
        //    if (ShouldKeepMapForRelic(sitePart))
        //    {
        //        sitePart.relicThing.DeSpawnOrDeselect();
        //        if (sitePart.relicThing.holdingOwner != null)
        //        {
        //            sitePart.relicThing.holdingOwner.Remove(sitePart.relicThing);
        //        }
        //        sitePart.relicWasSpawned = false;
        //    }
        //    else if (!sitePart.parms.relicLostSignal.NullOrEmpty())
        //    {
        //        Find.SignalManager.SendSignal(new Signal(sitePart.parms.relicLostSignal));
        //    }
        //}

        //public override string GetPostProcessedThreatLabel(Site site, SitePart sitePart)
        //{
        //    if (site.MainSitePartDef == def)
        //    {
        //        return null;
        //    }
        //    return base.GetPostProcessedThreatLabel(site, sitePart);
        //}
    } 
}
